<extend name="./Application/Admin/View/Layout/application.html"/>

<block name="content">
    <div class="row">
        <div class="col-md-9">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h3 class="panel-title">新增栏目</h3>
                </div>
                <div class="panel-body">


                    <ul class="nav nav-tabs" role="tablist">
                        <li role="presentation" class="active">
                            <a href="#home" aria-controls="home" role="tab" data-toggle="tab">增加栏目</a>
                        </li>
                        <li role="presentation">
                            <a href="#profile" aria-controls="profile" role="tab" data-toggle="tab">栏目内容</a>
                        </li>
                    </ul>

                    <!-- Tab panes -->
                    <form class="form-horizontal fade in active"  method="post" action="">

                        <div class="tab-content">
                            <div role="tabpanel" class="tab-pane active" id="home">
                                <div class="form-group">
                                    <label for="" class="col-sm-2 control-label">上级分类</label>
                                    <div class="col-sm-10">
                                        <select name="" id="" class="form-control">
                                            <option value="">请选择</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="name" class="col-sm-2 control-label">名称</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" name="name" id="name"
                                           value="{{$category.name}}"    placeholder="name">
                                    </div>
                                </div>


                                <div class="form-group">
                                    <label for="thumb" class="col-md-2 control-label">缩略图</label>

                                    <div class="col-sm-6">
                                        <input type="text" id="thumb" class="form-control" name="thumb" value="{{$category.thumb}}">
                                    </div>
                                    <div class="col-sm-3">
                                        <input type="button" value="上 传" id="ck_thumb_upload" class="btn btn-success"/>
                                    </div>
                                </div>
                                <!--缩略图显示-->
                                <div class="form-group">
                                    <div class="col-sm-offset-3 col-sm-10">
                                        <img src="{{$category.thumb}}" id="img_show" width="300px" height="100px"/>
                                    </div>
                                </div>

                                <div class="form-group">
                                    <label for="" class="col-sm-2 control-label">是否显示</label>
                                    <div class="col-sm-10">
                                        <label class="radio-inline">
                                            <<input type="radio" name="is_show" value="1" <eq name="category.is_show" value="1">checked</eq>> 是
                                        </label>
                                        <label class="radio-inline">
                                            <input type="radio" name="is_show" value="0" <eq name="category.is_show" value="0">checked</eq>> 否
                                        </label>
                                    </div>
                                </div>

                                <div class="form-group">
                                    <label for="" class="col-sm-2 control-label">类型</label>
                                    <div class="col-sm-10">
                                        <label class="radio-inline">
                                            <input type="radio" name="type" value="1" <eq name="category.type" value="1">checked</eq>> 封面
                                        </label>
                                        <label class="radio-inline">
                                            <input type="radio" name="type" value="2" <eq name="category.type" value="2">checked</eq>> 列表
                                        </label>
                                        <label class="radio-inline">
                                            <input type="radio" name="type" value="3" <eq name="category.type" value="3">checked</eq>> 跳转
                                        </label>
                                    </div>
                                </div>

                                <div class="form-group">
                                    <label for="url" class="col-sm-2 control-label">URL地址</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" name="url" value="{{$category.url}}" id="url" placeholder="url">
                                    </div>
                                </div>


                            </div>
                            <div role="tabpanel" class="tab-pane fade" id="profile">
                                <textarea name="content" id="ckeditor" cols="30" rows="10">{{$category.content}}</textarea>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-offset-2 col-sm-10">
                                <button type="submit" class="btn btn-primary">保 存</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</block>
<block name="js">
    <script src="__PUBLIC__/vendor/ckeditor/ckeditor.js"></script>
    <script src="__PUBLIC__/vendor/ckfinder/ckfinder.js"></script>
    <script>
        CKEDITOR.replace('ckeditor', {
            language: 'zh-cn',
            filebrowserBrowseUrl: '__PUBLIC__/vendor/ckfinder/ckfinder.html',
            filebrowserImageBrowseUrl: '__PUBLIC__/vendor/ckfinder/ckfinder.html?type=Images',
            filebrowserFlashBrowseUrl: '__PUBLIC__/vendor/ckfinder/ckfinder.html?type=Flash',
            filebrowserUploadUrl: '__PUBLIC__/vendor/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files',
            filebrowserImageUploadUrl: '__PUBLIC__/vendor/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Images',
            filebrowserFlashUploadUrl: '__PUBLIC__/vendor/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Flash'
        });
        $("#ck_thumb_upload").click(function () {
            CKFinder.modal({
                chooseFiles: true,
                language: 'zh-cn',
                onInit: function (finder) {
                    finder.on('files:choose', function (evt) {
                        var url = evt.data.files.first().getUrl();
                        $("#thumb").val(url);
                        $("#img_show").attr('src', url);
                    });

                    finder.on('file:choose:resizedImage', function (evt) {
                        var url = evt.data.resizedUrl;
                        $("#thumb").val(url);
                        $("#img_show").attr('src', url);
                    });
                }
            });
        });
    </script>
</block>

